package cn.com.connected.common.config.oss;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConfigurationProperties(prefix = "aliyun.properties.oss")
@Setter
@Getter
@Configuration("aliyunOssProperties")
public class AliyunOssProperties {

    public static final String beanName = "aliyunOssProperties";

    private String accessKeyId;

    private String accessKeySecret;

    //访问OSS的域名
    private String endpoint;

    private String openBucketName;

    private String openAccessHost;


    /**
     * 客户端oss上传
     * @return
     */
    @Bean(name = "appOssClient")
    public OSS getOssClient(){
        OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        return oss;
    }
}